<!DOCTYPE html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/blog/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/blog/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/blog/css/main.css?v=5.1.2" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Hexo, NexT" />








  <link rel="shortcut icon" type="image/x-icon" href="/blog/favicon.ico?v=5.1.2" />






<meta name="description" content="微信扫码登录开发指南网站应用微信登录是基于OAuth2.0协议标准构建的微信OAuth2.0授权登录系统。 授权流程说明微信OAuth2.0授权登录让微信用户使用微信身份安全登录第三方应用或网站，在微信用户授权登录已接入微信OAuth2.0的第三方应用后，第三方可以获取到用户的接口调用凭证（access_token），通过access_token可以进行微信开放平台授权关系接口调用，从而可实现获取">
<meta property="og:type" content="article">
<meta property="og:title" content="微信扫码登录">
<meta property="og:url" content="http://xiezixi.oschina.io/2018/05/16/微信登录/index.html">
<meta property="og:site_name" content="个人博客">
<meta property="og:description" content="微信扫码登录开发指南网站应用微信登录是基于OAuth2.0协议标准构建的微信OAuth2.0授权登录系统。 授权流程说明微信OAuth2.0授权登录让微信用户使用微信身份安全登录第三方应用或网站，在微信用户授权登录已接入微信OAuth2.0的第三方应用后，第三方可以获取到用户的接口调用凭证（access_token），通过access_token可以进行微信开放平台授权关系接口调用，从而可实现获取">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="http://xiezixi.oschina.io/blog/images/获取access_token时序图.png">
<meta property="og:updated_time" content="2018-05-16T01:17:36.747Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="微信扫码登录">
<meta name="twitter:description" content="微信扫码登录开发指南网站应用微信登录是基于OAuth2.0协议标准构建的微信OAuth2.0授权登录系统。 授权流程说明微信OAuth2.0授权登录让微信用户使用微信身份安全登录第三方应用或网站，在微信用户授权登录已接入微信OAuth2.0的第三方应用后，第三方可以获取到用户的接口调用凭证（access_token），通过access_token可以进行微信开放平台授权关系接口调用，从而可实现获取">
<meta name="twitter:image" content="http://xiezixi.oschina.io/blog/images/获取access_token时序图.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/blog/',
    scheme: 'Muse',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://xiezixi.oschina.io/2018/05/16/微信登录/"/>





  <title>微信扫码登录 | 个人博客</title>
  














</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">
  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/blog/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">个人博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">曦瓜皮</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/blog/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/blog/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/blog/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      

      
    </ul>
  

  
</nav>


 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://xiezixi.oschina.io/blog/2018/05/16/微信登录/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="曦瓜皮">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="个人博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">微信扫码登录</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-05-16T09:17:36+08:00">
                2018-05-16
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/Wechat/" itemprop="url" rel="index">
                    <span itemprop="name">Wechat</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="微信扫码登录开发指南"><a href="#微信扫码登录开发指南" class="headerlink" title="微信扫码登录开发指南"></a>微信扫码登录开发指南</h2><p>网站应用微信登录是基于OAuth2.0协议标准构建的微信OAuth2.0授权登录系统。</p>
<h3 id="授权流程说明"><a href="#授权流程说明" class="headerlink" title="授权流程说明"></a>授权流程说明</h3><p>微信OAuth2.0授权登录让微信用户使用微信身份安全登录第三方应用或网站，在微信用户授权登录已接入微信OAuth2.0的第三方应用后，第三方可以获取到用户的接口调用凭证（access_token），通过access_token可以进行微信开放平台授权关系接口调用，从而可实现获取微信用户基本开放信息和帮助用户实现基础开放功能等。</p>
<h3 id="授权整体流程"><a href="#授权整体流程" class="headerlink" title="授权整体流程"></a>授权整体流程</h3><blockquote>
<ol>
<li>第三方发起微信授权登录请求，微信用户允许授权第三方应用后，微信会拉起应用或重定向到第三方网站，并且带上授权临时票据code参数；</li>
<li>通过code参数加上AppID和AppSecret等，通过API换取access_token；</li>
<li>通过access_token进行接口调用，获取用户基本数据资源或帮助用户实现基本操作。</li>
</ol>
</blockquote>
<h3 id="获取access-token时序图"><a href="#获取access-token时序图" class="headerlink" title="获取access_token时序图"></a>获取access_token时序图</h3><p><img src="http://xiezixi.oschina.io/blog/images/获取access_token时序图.png" alt="获取access_token时序图"></p>
<h2 id="微信扫码登录方式及区别"><a href="#微信扫码登录方式及区别" class="headerlink" title="微信扫码登录方式及区别"></a>微信扫码登录方式及区别</h2><h3 id="平台分类"><a href="#平台分类" class="headerlink" title="平台分类"></a>平台分类</h3><blockquote>
<ul>
<li><a href="https://open.weixin.qq.com/" target="_blank" rel="noopener">微信开放平台</a></li>
<li><a href="https://mp.weixin.qq.com/" target="_blank" rel="noopener">微信公众平台</a></li>
</ul>
</blockquote>
<h3 id="扫码登录API"><a href="#扫码登录API" class="headerlink" title="扫码登录API"></a>扫码登录API</h3><blockquote>
<ul>
<li><a href="https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&amp;t=resource/res_list&amp;verify=1&amp;id=open1419316505&amp;token=&amp;lang=zh_CN" target="_blank" rel="noopener">微信开放平台扫码登录</a></li>
<li><a href="https://mp.weixin.qq.com/wiki?t=resource/res_main&amp;id=mp1421140842" target="_blank" rel="noopener">微信公众平台扫码登录</a></li>
</ul>
</blockquote>
<h3 id="两者区别与联系"><a href="#两者区别与联系" class="headerlink" title="两者区别与联系"></a>两者区别与联系</h3><blockquote>
<ol>
<li>两者都可以通过微信客户端扫码授权的方式，让第三方页面获得微信用户的一些基本信息（昵称、性别、所在地、在微信唯一标示等……）。两者都是通过提供一个链接让用户授权的方式。但网页版需要在页面打开二维码之后授权，而公众号则需要用户先关注公众号，然后点开公众号里面的链接，确认授权即可;</li>
<li>网页扫码登录需要将授权的链接（二维码链接）在网页中打开、而公众号授权登录的链接必须要微信客户端中打开;</li>
<li>无论网页扫码登录还是在公众号中授权登录，都是通过授权的方式获得一个code参数，之后通过code参数获取access_token和openid和通过access_token和openid去获取用户的基本信息，接口请求链接是一样的</li>
<li>微信公众平台提供测试号，但开放平台需要花钱注册。</li>
</ol>
</blockquote>
<h2 id="公众号扫码登录Demo"><a href="#公众号扫码登录Demo" class="headerlink" title="公众号扫码登录Demo"></a>公众号扫码登录Demo</h2><h3 id="生成在线二维码"><a href="#生成在线二维码" class="headerlink" title="生成在线二维码"></a>生成在线二维码</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc2534e9ca299601d&amp;redirect_uri=http%3A%2F%2Fxiezixi.tunnel.echomod.cn%2Fwechat%2Flogin&amp;response_type=code&amp;scope=snsapi_userinfo&amp;state=11#wechat_redirect</span><br></pre></td></tr></table></figure>
<h3 id="AuthUtil"><a href="#AuthUtil" class="headerlink" title="AuthUtil"></a>AuthUtil</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> com.xzx.wechatLogin.wechat.util;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> com.alibaba.fastjson.JSON;</span><br><span class="line"><span class="keyword">import</span> com.alibaba.fastjson.JSONObject;</span><br><span class="line"><span class="keyword">import</span> org.apache.http.client.fluent.Request;</span><br><span class="line"><span class="keyword">import</span> org.apache.http.client.utils.URIBuilder;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.io.IOException;</span><br><span class="line"><span class="keyword">import</span> java.net.URISyntaxException;</span><br><span class="line"><span class="keyword">import</span> java.nio.charset.Charset;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">AuthUtil</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> String APP_ID = <span class="string">"wxc2534e9ca299601d"</span>;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> String APP_SECRET = <span class="string">"c3489bf8d1325ec8b271b243bb09198b"</span>;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> String GRANT_TYPE = <span class="string">"authorization_code"</span>;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 通过code获取access_token</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@param</span> code</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">     * <span class="doctag">@throws</span> IOException</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@throws</span> URISyntaxException</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> JSONObject <span class="title">getAccessToken</span><span class="params">(String code)</span> <span class="keyword">throws</span> IOException, URISyntaxException </span>&#123;</span><br><span class="line">        URIBuilder uriBuilder = <span class="keyword">new</span> URIBuilder()</span><br><span class="line">                .setScheme(<span class="string">"https"</span>)</span><br><span class="line">                .setHost(<span class="string">"api.weixin.qq.com"</span>)</span><br><span class="line">                .setPath(<span class="string">"/sns/oauth2/access_token"</span>)</span><br><span class="line">                .addParameter(<span class="string">"appid"</span>, APP_ID)</span><br><span class="line">                .addParameter(<span class="string">"secret"</span>,APP_SECRET)</span><br><span class="line">                .addParameter(<span class="string">"code"</span>,code)</span><br><span class="line">                .addParameter(<span class="string">"grant_type"</span>,GRANT_TYPE);</span><br><span class="line">        String content = Request.Get(uriBuilder.build()).connectTimeout(<span class="number">10000</span>)</span><br><span class="line">                .execute().returnContent().asString(Charset.defaultCharset());</span><br><span class="line">        <span class="keyword">return</span> JSON.parseObject(content);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 通过access_token和open_id获取用户基本信息</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@param</span> accessToken</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@param</span> openId</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">     * <span class="doctag">@throws</span> IOException</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@throws</span> URISyntaxException</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> JSONObject <span class="title">getUserInfo</span><span class="params">(String accessToken,String openId)</span> <span class="keyword">throws</span> IOException, URISyntaxException </span>&#123;</span><br><span class="line">        URIBuilder uriBuilder = <span class="keyword">new</span> URIBuilder()</span><br><span class="line">                .setScheme(<span class="string">"https"</span>)</span><br><span class="line">                .setHost(<span class="string">"api.weixin.qq.com"</span>)</span><br><span class="line">                .setPath(<span class="string">"/sns/userinfo"</span>)</span><br><span class="line">                .addParameter(<span class="string">"access_token"</span>, accessToken)</span><br><span class="line">                .addParameter(<span class="string">"openid"</span>, openId);</span><br><span class="line">        <span class="comment">// GET</span></span><br><span class="line">        String content = Request.Get(uriBuilder.build()).connectTimeout(<span class="number">10000</span>)</span><br><span class="line">                .execute().returnContent().asString(Charset.defaultCharset());</span><br><span class="line">        <span class="keyword">return</span> JSON.parseObject(content);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="LoginController"><a href="#LoginController" class="headerlink" title="LoginController"></a>LoginController</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> com.xzx.wechatLogin.wechat.controller;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> com.alibaba.fastjson.JSONObject;</span><br><span class="line"><span class="keyword">import</span> com.xzx.wechatLogin.wechat.util.AuthUtil;</span><br><span class="line"><span class="keyword">import</span> org.slf4j.Logger;</span><br><span class="line"><span class="keyword">import</span> org.slf4j.LoggerFactory;</span><br><span class="line"><span class="keyword">import</span> org.springframework.web.bind.annotation.GetMapping;</span><br><span class="line"><span class="keyword">import</span> org.springframework.web.bind.annotation.RequestMapping;</span><br><span class="line"><span class="keyword">import</span> org.springframework.web.bind.annotation.RequestParam;</span><br><span class="line"><span class="keyword">import</span> org.springframework.web.bind.annotation.RestController;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.io.IOException;</span><br><span class="line"><span class="keyword">import</span> java.net.URISyntaxException;</span><br><span class="line"><span class="keyword">import</span> java.util.HashMap;</span><br><span class="line"></span><br><span class="line"><span class="meta">@RestController</span></span><br><span class="line"><span class="meta">@RequestMapping</span>(<span class="string">"/wechat"</span>)</span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">LoginController</span> </span>&#123;</span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> Logger log = LoggerFactory.getLogger(LoginController.class);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> HashMap&lt;String,String&gt; userMap = <span class="keyword">new</span> HashMap&lt;&gt;();</span><br><span class="line"></span><br><span class="line">    <span class="meta">@GetMapping</span>(<span class="string">"/binding"</span>)</span><br><span class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">binding</span><span class="params">(@RequestParam String code, @RequestParam String state)</span> <span class="keyword">throws</span> IOException, URISyntaxException </span>&#123;</span><br><span class="line">        JSONObject accessToken = AuthUtil.getAccessToken(code);</span><br><span class="line">        log.info(<span class="string">"userId: &#123;&#125; , open_id: &#123;&#125;"</span>, state,accessToken.getString(<span class="string">"openid"</span>));</span><br><span class="line">        userMap.put(accessToken.getString(<span class="string">"openid"</span>),state);</span><br><span class="line">        <span class="keyword">return</span> <span class="string">"绑定成功"</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@GetMapping</span>(<span class="string">"/login"</span>)</span><br><span class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">login</span><span class="params">(@RequestParam String code, @RequestParam String state)</span> <span class="keyword">throws</span> IOException, URISyntaxException </span>&#123;</span><br><span class="line">        JSONObject accessToken = AuthUtil.getAccessToken(code);</span><br><span class="line">        log.info(<span class="string">"open_id: &#123;&#125;"</span>, state,accessToken.getString(<span class="string">"openid"</span>));</span><br><span class="line">        <span class="keyword">if</span> (userMap.get(accessToken.getString(<span class="string">"openid"</span>)) == <span class="keyword">null</span>)&#123;</span><br><span class="line">            <span class="keyword">return</span> <span class="string">"请先注册，再绑定微信"</span>;</span><br><span class="line">        &#125;<span class="keyword">else</span> &#123;</span><br><span class="line">            <span class="keyword">return</span> <span class="string">"已绑定，登录成功"</span>;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/blog/2018/05/15/linux基本命令/" rel="next" title="Linux基本命令">
                <i class="fa fa-chevron-left"></i> Linux基本命令
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/blog/2018/06/01/HTML5-WebSocket/" rel="prev" title="HTML5 之 WebSocket™">
                HTML5 之 WebSocket™ <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/blog/images/avatar.jpg"
               alt="曦瓜皮" />
          <p class="site-author-name" itemprop="name">曦瓜皮</p>
           
              <p class="site-description motion-element" itemprop="description"></p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/blog/archives/">
                <span class="site-state-item-count">15</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/blog/categories/index.html">
                <span class="site-state-item-count">6</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          

        </nav>

        

        <div class="links-of-author motion-element">
          
        </div>

        
        

        
        

        

      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#微信扫码登录开发指南"><span class="nav-number">1.</span> <span class="nav-text">微信扫码登录开发指南</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#授权流程说明"><span class="nav-number">1.1.</span> <span class="nav-text">授权流程说明</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#授权整体流程"><span class="nav-number">1.2.</span> <span class="nav-text">授权整体流程</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#获取access-token时序图"><span class="nav-number">1.3.</span> <span class="nav-text">获取access_token时序图</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#微信扫码登录方式及区别"><span class="nav-number">2.</span> <span class="nav-text">微信扫码登录方式及区别</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#平台分类"><span class="nav-number">2.1.</span> <span class="nav-text">平台分类</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#扫码登录API"><span class="nav-number">2.2.</span> <span class="nav-text">扫码登录API</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#两者区别与联系"><span class="nav-number">2.3.</span> <span class="nav-text">两者区别与联系</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#公众号扫码登录Demo"><span class="nav-number">3.</span> <span class="nav-text">公众号扫码登录Demo</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#生成在线二维码"><span class="nav-number">3.1.</span> <span class="nav-text">生成在线二维码</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#AuthUtil"><span class="nav-number">3.2.</span> <span class="nav-text">AuthUtil</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#LoginController"><span class="nav-number">3.3.</span> <span class="nav-text">LoginController</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">曦瓜皮</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Muse
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/blog/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/blog/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/blog/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/blog/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/blog/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/blog/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/blog/js/src/utils.js?v=5.1.2"></script>

  <script type="text/javascript" src="/blog/js/src/motion.js?v=5.1.2"></script>



  
  

  
  <script type="text/javascript" src="/blog/js/src/scrollspy.js?v=5.1.2"></script>
<script type="text/javascript" src="/blog/js/src/post-details.js?v=5.1.2"></script>



  


  <script type="text/javascript" src="/blog/js/src/bootstrap.js?v=5.1.2"></script>



  


  




	





  





  






  





  

  

  

  

  

  

</body>
</html>
